/* C++异常 */
#include <iostream>
#include <string>

using namespace std;

void test(void)
{
    string str("hello");
    cout << "开始抛出异常" << endl;

    /* 抛出异常 */
    throw str;

    cout << "结束" << endl;


    return;
}

int main(int argc, char **argv)
{

    try
    {
        test();
    }
    catch (int)
    {
        cout << "捕获到int异常" << endl;
    }
    catch (char)
    {
        cout << "捕获到char异常" << endl;
    }
    catch (char const *)
    {
        cout << "捕获到char *异常" << endl;
    }
    catch (string)
    {
        cout << "捕获到string异常" << endl;
    }
    catch (...)
    {
        cout << "捕获所有的异常" << endl;
    }
    


    return 0;
}